#include "HiranipraShared.h"

#ifndef _SHARED_MATH_SPHERE_H_
#define _SHARED_MATH_SPHERE_H_

namespace Hiranipra {
	namespace Math {

		typedef struct Sphere_t {
			Vector Location;
			float Radius;
		} Sphere;

		FORCE_INLINE bool PointInSphere( const Point3D& point, const Sphere& sphere )
		{
			return Distance( point, sphere.Location ) <= sphere.Radius;
		}

		FORCE_INLINE bool PointInSphere( const Vector& point, const Sphere& sphere )
		{
			return Distance( point, sphere.Location ) <= sphere.Radius;
		}

		FORCE_INLINE bool SphereSphereHasIntersection( const Sphere& s1, const Sphere& s2 )
		{
			float distance = Distance( s1.Location, s2.Location );
			return distance <= ( s1.Radius + s2.Radius );
		}

		INLINE Intersection SphereSphereIntersects( const Sphere& s1, const Sphere& s2 )
		{
			float distance = Distance( s1.Location, s2.Location );
			if( distance > ( s1.Radius + s2.Radius ) )
				return Math::NoIntersection;
			else if( distance <= MAX( s1.Radius, s2.Radius ) )
				return Math::Inside;
			else
				return Math::Overlap;
		}

	}
}

#endif // _SHARED_MATH_SPHERE_H_